package com.jhx.common.utils

import android.content.Context
import android.view.Gravity
import android.view.View
import android.widget.Toast

/**
 * context 扩展函数
 *
 * @author Jack 2018-03-08 19:19
 */
 fun Context.toast(msg: String?) {
    Toast.makeText(this, "$msg", Toast.LENGTH_SHORT).show()
 }

 fun Context.centerToast(msg: String?) {
     val toast = Toast.makeText(this, "$msg", Toast.LENGTH_SHORT)
     toast.setGravity(Gravity.CENTER, 0, 0)
     toast.show()
 }

 fun Context.customToast(view: View?) {
     if(view != null) {
         val toast = Toast(this)
         toast.setGravity(Gravity.CENTER, 0, 0)
         toast.view = view
         toast.show()
     }
 }